import com.alibaba.fastjson.JSON;
import com.aliyun.odps.udf.UDF;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SpliderVolumeMatterData extends UDF{
	
	
	/*
	 * public static void main(String[] args) { String volume =
	 * "Huile, Shower Oil: 30ml / Perfume: 50ml"; evaluate(volume); }
	 */
	 
	
	public String evaluate(String	volume) {
		List<String> volumeList = new ArrayList<String>();
		if(volume.contains(",")) {
			String[] volumeArr = volume.split(",");
			volumeList = Arrays.asList(volumeArr);
		}else if(volume.contains("/")) {
			String[] volumeArr = volume.split("/");
			volumeList = Arrays.asList(volumeArr);
		}else {
			volumeList.add(volume);
		}
		System.out.println(JSON.toJSONString(volumeList));
		String result = "";
		if(volumeList.size() != 0) {
			for(String vol :volumeList) {
				if(vol.contains(":")) {
					String netContent = vol.split(":")[1].trim();
					result = result+netContent+",";
				}else {
					String netContent =vol.trim();
					result = result+netContent+",";
				}
			}
		}
		result = result.substring(0, result.lastIndexOf(","));
		System.out.println(result);
		return result;
	}
}
